package cn.nexd.collector.bean;

import android.net.wifi.ScanResult;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by codngfish on 16/5/19.
 */
public class WifiScannerResultStory {

    private List<WifiCollectorResult> wifiCollectorResults;

    public synchronized List<WifiCollectorResult> getWifiCollectorResults() {
        List<WifiCollectorResult> wifiCollectorResultList = new ArrayList<>();
        wifiCollectorResultList.addAll(wifiCollectorResults);
        wifiCollectorResults.clear();
        return wifiCollectorResultList;
    }

    public WifiScannerResultStory() {
        wifiCollectorResults = new ArrayList<>();
    }

    public synchronized void addWifiCollectorResult(List<ScanResult> scanResults) {
        for (ScanResult scanResult : scanResults) {
            WifiCollectorResult wifiCollectorResult = new WifiCollectorResult();
            wifiCollectorResult.setTimestamp(scanResult.timestamp);
            wifiCollectorResult.setEndRssi(scanResult.level);
            wifiCollectorResult.setEndTimestamp(scanResult.timestamp);
            wifiCollectorResult.setRssi(scanResult.level);
            wifiCollectorResult.setStartRssi(scanResult.level);
            wifiCollectorResult.setWifiAddress(scanResult.BSSID);
            wifiCollectorResult.setWifiName(scanResult.SSID);
            wifiCollectorResults.add(wifiCollectorResult);
        }
    }
}
